package com.coco.result;



import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;
    private String request_id;
    private Result(){}

    /**
     * 成功不返回数据
     * @return
     * @param <T>
     */
    public static <T> Result<T> ok(){
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMsg("执行成功");
        return result;
    }
    public static <T> Result<T> ok(T data){
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMsg("执行成功");
        result.setData(data);
        return result;
    }
    public static <T> Result<T> error(String message) {
        Result<T> result = new Result<>();
        result.code = 500;
        result.msg = message;
        return result;
    }


    public Result<T> message(String message){
        this.setMsg(message);
        return this;
    }




}

